package com.cjxt.ams.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cjxt.ams.dao.UserDao;
import com.cjxt.ams.domain.User;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;

/**
 * @author zhanghuan
 * @version V1.0
 * @Description:
 * @className: AbstractController
 * @date 2021/11/24 10:19
 * @company:华勤技术股份有限公司
 * @copyright: Copyright (c) 2021
 */

public abstract class AbstractController {
	@Resource
	private UserDao userDao;

	protected Logger logger = LoggerFactory.getLogger(getClass());

	protected User getUser() {
		String aacount= (String) SecurityUtils.getSubject().getPrincipal();

		//String account = "zhangsan";
		QueryWrapper<User> qw = new QueryWrapper<>();
		QueryWrapper<User> userAccount = qw.eq("userAccount", aacount);

		return userDao.selectOne(userAccount);
	}

	protected Integer getUserId() {
		return getUser().getUserId();
	}

	protected Integer getDeptId() {
		return getUser().getDeptId();
	}
}
